public class Work7 {
    public static int hanoi(int n) {
        if (n == 1)
            return 1;
        else
            return 2 * hanoi(n - 1) + 1;
    }

    public static void main(String[] args) {
        //递归求解汉诺塔问题
        int n = 3;
        System.out.println(hanoi(n));
    }
}
